<%@ page language="java" import="com.alibaba.fastjson.JSONObject" pageEncoding="UTF-8" %>
<%@ page import="weaver.common.DateUtil" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%--更新统计台账是否已发送--%>
<%
    String id = Util.null2String(request.getParameter("id"));
    User user = HrmUserVarify.getUser(request, response);
    String userid = user.getUID() + "";
    RecordSet rs = new RecordSet();
    JSONObject jsonData = new JSONObject();
    String message = "";
    boolean flag = false;
    rs.executeQuery("select zkjssj from uf_kstjtz where id=? and cjr=?", id, userid);
    if (rs.next()) {
        String zkjssj = Util.null2String(rs.getString("zkjssj"));
        if (!"".equals(zkjssj) && hasThanCurDate(zkjssj + ":00")) {
            rs.executeUpdate("update uf_kstjtz set sfyfs=0 where id=?", id);
            message = "在线考试流程操作成功";
        } else {
            message = "重考截止时间未设置或已超过";
        }
    } else {
        message = "只有出卷人才能发送试卷";
    }
    jsonData.put("flag", flag);
    jsonData.put("message", message);
    out.print(jsonData.toJSONString());

%>
<%!
    /*
     * 参数日期是否大于当前日期
     */
    public static boolean hasThanCurDate(String date) {
        boolean flag = false;
        long ts1 = 0L;
        long ts2 = 0L;
        try {
            if (date.length() > 10) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date d1 = sdf.parse(date);
                ts1 = d1.getTime();
                Date d2 = sdf.parse(DateUtil.getFullDate());
                ts2 = d2.getTime();
            } else {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Date d1 = sdf.parse(date);
                ts1 = d1.getTime();
                Date d2 = sdf.parse(DateUtil.getCurrentDate());
                ts2 = d2.getTime();
            }
            if ((ts1 - ts2) >= 0) {
                flag = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }

%>